using System;
using System.Data;
using System.Linq;
using System.ComponentModel;
using System.Reflection;
using System.Collections.Generic;
using DataObject.Model;
using DataObject.Database;

	public partial class ServiceMapper
	{
		#region ToSingle

		public static ServiceDTO ToSingle(Service entity)
		{
			if (entity == null)
			{
				return null;
			}
			return new ServiceDTO
			{
				Active = entity.Active,
                NightFlag = entity.NightFlag,
				ChoiceOption = entity.ChoiceOption,
				Description = entity.Description,
				ModifiedBy = entity.ModifiedBy,
				ModifiedDate = entity.ModifiedDate,
				NumInPackage = entity.NumInPackage,
				OtherUom = entity.OtherUom,
				PackagePrice = entity.PackagePrice,
				ServiceCode = entity.ServiceCode,
				ServiceID = entity.ServiceID,
				ServiceName = entity.ServiceName,
                Unit = entity.Unit,
                Currency = entity.Currency,
                UnitPrice = entity.UnitPrice,
			};
		}

		#endregion

		#region ToEntity

		public static Service ToEntity(Service entity, ServiceDTO businessobject)
		{
			if (businessobject == null)
			{
				return null;
			}
			entity.Active = businessobject.Active;
            entity.NightFlag = businessobject.NightFlag;
			entity.ChoiceOption = businessobject.ChoiceOption;
			entity.Description = businessobject.Description;
			entity.ModifiedBy = businessobject.ModifiedBy;
			entity.ModifiedDate = businessobject.ModifiedDate;
			entity.NumInPackage = businessobject.NumInPackage;
			entity.OtherUom = businessobject.OtherUom;
			entity.PackagePrice = businessobject.PackagePrice;
			entity.ServiceCode = businessobject.ServiceCode;
			entity.ServiceID = businessobject.ServiceID;
			entity.ServiceName = businessobject.ServiceName;
            entity.Unit = businessobject.Unit;
            entity.Currency = businessobject.Currency;
            entity.UnitPrice = businessobject.UnitPrice;
			return entity;
		}

		#endregion

		#region ToBusinessObject

		public static ServiceDTO ToBusinessObject(Service entity)
		{
			if (entity == null)
			{
				return null;
			}
			return new ServiceDTO
			{
				Active = entity.Active,
                NightFlag = entity.NightFlag,
				ChoiceOption = entity.ChoiceOption,
				Description = entity.Description,
				ModifiedBy = entity.ModifiedBy,
				ModifiedDate = entity.ModifiedDate,
				NumInPackage = entity.NumInPackage,
				OtherUom = entity.OtherUom,
				PackagePrice = entity.PackagePrice,
				ServiceCode = entity.ServiceCode,
				ServiceID = entity.ServiceID,
				ServiceName = entity.ServiceName,
                Unit = entity.Unit,
                Currency = entity.Currency,
                UnitPrice = entity.UnitPrice
			};
		}

		#endregion

		#region ToBusinessObjectHasChildren

		public static ServiceDTO ToBusinessObjectHasChildren(Service entity, params Type[] types)
		{
			if (entity == null)
			{
				return null;
			}
			ServiceDTO businessobject = new ServiceDTO
			{
				Active = entity.Active,
                NightFlag = entity.NightFlag,
				ChoiceOption = entity.ChoiceOption,
				Description = entity.Description,
				ModifiedBy = entity.ModifiedBy,
				ModifiedDate = entity.ModifiedDate,
				NumInPackage = entity.NumInPackage,
				OtherUom = entity.OtherUom,
				PackagePrice = entity.PackagePrice,
				ServiceCode = entity.ServiceCode,
				ServiceID = entity.ServiceID,
				ServiceName = entity.ServiceName,
                Unit = entity.Unit,
                Currency = entity.Currency,
                UnitPrice = entity.UnitPrice
			};
			if (types.Contains<Type>(typeof(ReservationService)) || types.Length == 0)
			{
				businessobject.ReservationServiceCollection = new List<ReservationServiceDTO>();
				foreach(var item in entity.ReservationServices)
				{
					businessobject.ReservationServiceCollection.Add(ReservationServiceMapper.ToBusinessObject(item));
				}
			}
			if (types.Contains<Type>(typeof(RouteService)) || types.Length == 0)
			{
				businessobject.RouteServiceCollection = new List<RouteServiceDTO>();
				foreach(var item in entity.RouteServices)
				{
                    businessobject.RouteServiceCollection.Add(RouteServiceMapper.ToBusinessObject(item));
				}
			}
			if (types.Contains<Type>(typeof(ServiceProvider)) || types.Length == 0)
			{
				businessobject.ServiceProviderCollection = new List<ServiceProviderDTO>();
				foreach(var item in entity.ServiceProviders)
				{
                    businessobject.ServiceProviderCollection.Add(ServiceProviderMapper.ToBusinessObject(item));
				}
			}
			return businessobject;
		}

		#endregion

	}
